< previous page page_286 next page >

Page 286
z0306-01.gif
Figure 10.5
A depth seven tree with a variable number of bending branches.
The bend parameter indicates by how much the branch should bend as it grows. If bend is zero, the branch is straight. Otherwise, the direction of each segment in a branch is modified by a random amount between -bend/2 and bend/2 radians. When the subroutine recursively calls itself, it increases the bend parameter so that smaller branches are likely to bend more than larger branches.
e10a6a0a59f035e870d90cca05b85fce.gif
' Recursively draw a tree branch.
Private Sub DrawBranch(ByVal bend As Single, _
    ByVal thickness As Single, ByVal Depth As Integer, _
    ByVal X As Single, ByVal Y As Single, _
    ByVal length As Single, ByVal length_scale As Single, _
    ByVal rnd_scale As Single, ByVal theta As Single, _
    ByVal dtheta As Single, ByVal rnd_dtheta As Single, _
    ByVal max_branches As Integer)
Const DIST_PER_BEND = 5#
Const BEND_FACTOR = 2#
Const MAX_BEND = PI / 6

Dim x1 As Integer

 
< previous page page_286 next page >